<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>给对象绑定事件</title>
</head>
<body>
           <input type="button" name="btn" value="点我一下" id="box">
            <script>
               function foo() {
                   alert('今天是晴天')
               }
               document.getElementById('box').onclick = foo
            </script>
</body>
</html>